import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.GifCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;

import java.awt.*;
import java.io.File;

public class QRCode {

    public static void main(String[] args) throws Exception {
        GifCaptcha gifCaptcha = CaptchaUtil.createGifCaptcha(150, 50);
        gifCaptcha.setGenerator(new RandomGenerator("0123456789", 4));
        gifCaptcha.setBackground(new Color(248, 248, 248));
        gifCaptcha.setMaxColor(60);
        gifCaptcha.setMinColor(55);
        System.out.println(gifCaptcha.getCode());
//        gifCaptcha.getImageBase64Data()
        System.out.println(gifCaptcha.getImageBase64Data());
        File file = new File("D:\\myproject\\idea\\my\\mySys\\web-admin\\src\\main\\test");
        if(!file.exists()){
            file.mkdirs();
        }
        gifCaptcha.write(new File(file, "test.png"));
    }

}
